package com.uduew.sjd.bean;

import androidx.annotation.Nullable;

import java.util.Map;

import okhttp3.Headers;

public class HttpBean<T> {
    /** 响应头 */
    @Nullable
    private Map<String, String> responseHeaders;

    /** 返回码 */
    private String phylogenic;
    /** 提示语 */
    private String blatherskite;

    private int code;
    /** 提示语 */
    private String msg;


    /** 数据 */
    @Nullable
    private T overripe;

    @Nullable
    private T data;


    public void setResponseHeaders(@Nullable Map<String, String> responseHeaders) {
        this.responseHeaders = responseHeaders;
    }

    @Nullable
    public Map<String, String> getResponseHeaders() {
        return responseHeaders;
    }

    public String getCode() {
        return phylogenic;
    }

    public void setCode(String code) {
        this.phylogenic = code;
    }

    public String getMsg2() {
        return msg;
    }


    public String getMsg() {
        return blatherskite;
    }

    public void setMsg(String blatherskite) {
        this.blatherskite = blatherskite;
    }

    @Nullable
    public T getData() {
        return overripe;
    }

    @Nullable
    public T getData2() {
        return data;
    }

    public boolean isRequestSuccess() {
        return (phylogenic != null && phylogenic.equals("0")) || code == 200;
    }

    /**
     * 是否 Token 失效
     * 1403 您的账号已在其他设备上登录，点击确定跳登录注册页面
     * 1012要让用户跳转登录，重新登录
     */
    public boolean isTokenInvalidation() {
        return phylogenic.equals("1012") || phylogenic.equals("1403");
    }

    @Override
    public String toString() {
        return "HttpBean{" +
                "responseHeaders=" + responseHeaders +
                ", code=" + phylogenic +
                ", msg='" + blatherskite + '\'' +
                ", data=" + overripe +
                '}';
    }
}
